Skip to content

fix(aggregator): body amount fallback — standalone total, paid labels win (#3121) - #3164

Merged
dezren39 merged 2 commits into
mainfrom
queue/4554-3121-subtotal-total
Oct 31, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/4554-3121-subtotal-total

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Fixes #3121 (Codex P2 from PR #2149, comment 4409381673, merged undispositioned).

The Gmail body-amount fallback regex had total as an unbounded alternative, so it matched the "total" inside "Subtotal": a body Subtotal $20.00 / Tax $1.60 / Total $21.60 recorded $20.00, and since exec() takes the first match, a later Amount paid $21.60 never won. The wrong amount also defeats cross-source dedupe.

Change (pm-stack/aggregator/scripts/produce-charge-candidates.ts):

  • Extraction moved to an exported amountFromBody(): explicit paid/charged labels (amount paid | amount charged | total charged | transaction amount) win first; a standalone \btotal label is next (word boundary — "Subtotal" cannot match); any $ amount remains the last-resort fallback, as before.
  • main() is now behind import.meta.main so the script is importable by tests without running the producer.

Tests (test/produce-charge-candidates.test.ts, new): Subtotal/Tax/Total + later Amount paid records 21.60; later Amount paid beats an earlier bare Total; standalone Total used when no paid label exists; total charged counts as paid/charged; no-amount body yields undefined. 5/5 pass on the laptop. Full aggregator suite: 712 pass / 7 fail — the 7 (page-manifest/nav renders) fail identically on clean origin/main in the same environment (verified via stash), pre-existing and unrelated.

Queue task 4554.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 17:42
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 805dd620-67b1-4e3b-bc6f-4fdc4ea2d81d
Commits

Reviewing files that changed from the base of the PR and between 5cc6bad and 1eb99ef.

Files selected for processing: 2
  • pm-stack/aggregator/scripts/produce-charge-candidates.ts
  • pm-stack/aggregator/test/produce-charge-candidates.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T18:43:08.229816Z 1eb99ef New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 749c90ccdc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39
dezren39 merged commit faa3895 into main Oct 31, 2026
1 check passed
@dezren39
dezren39 deleted the queue/4554-3121-subtotal-total branch October 31, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(aggregator): charges producer body fallback matches 'total' inside 'Subtotal', recording the subtotal as the charge (PR #2149)

1 participant